#include "wx/wxprec.h"
#include "wx/xrc/xh_scwin.h"

IMPLEMENT_DYNAMIC_CLASS( wxScrolledWindowXmlHandler, wxXmlResourceHandler )

wxScrolledWindowXmlHandler::wxScrolledWindowXmlHandler()
  : wxXmlResourceHandler() {
  XRC_ADD_STYLE( wxHSCROLL );
  XRC_ADD_STYLE( wxVSCROLL );
  XRC_ADD_STYLE( wxNO_3D );
  XRC_ADD_STYLE( wxTAB_TRAVERSAL );
  XRC_ADD_STYLE( wxWS_EX_VALIDATE_RECURSIVELY );
  AddWindowStyles();
}

wxObject *wxScrolledWindowXmlHandler::DoCreateResource() {
  XRC_MAKE_INSTANCE( control, wxScrolledWindow )
  control->Create( m_parentAsWindow,
                   GetID(),
                   GetPosition(), GetSize(),
                   GetStyle( wxT( "style" ), wxHSCROLL | wxVSCROLL ),
                   GetName() );
  SetupWindow( control );
  CreateChildren( control );
  if( HasParam( wxT( "scrollrate" ) ) ) {
    wxSize rate = GetSize( wxT( "scrollrate" ) );
    control->SetScrollRate( rate.x, rate.y );
  }
  return control;
}

bool wxScrolledWindowXmlHandler::CanHandle( wxXmlNode *node ) {
  return IsOfClass( node, wxT( "wxScrolledWindow" ) );
}
